package nc.hw;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class HJ41 {

    private static Set<Integer> weight(Set<Integer> weights, int nums, int weight) {
        Set<Integer> ints = new HashSet<>();
        for (int i = 0; i <= nums; i++) {
            int w = weight * i;
            for (Integer integer : weights) {
                int o = w + integer;
                ints.add(o);
            }
        }
        return ints;
    }

    private static int times(int[] ms, int[] xs) {
        Set<Integer> weights = new HashSet<>();
        weights.add(0);
        for (int i = 0; i < ms.length; i++) {
            weights = weight(weights, xs[i], ms[i]);
        }
        return weights.size();
    }

    public static void main(String[] args) {
        System.out.println(times(new int[]{2000,1999,1998,1997,1996,1995,1994,1993,1992,1991 },
                new int[]{10,10,10,10,10,10,10,10,10,10}));
    }

}
